<?php


namespace app\api\controller;


use app\common\controller\Api;
use app\common\model\Slide;
use app\common\model\SlideItem;
use app\common\model\SysMessage;
use app\common\model\SysMessageCategory;

class Publics extends Api{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';

    public function _initialize()
    {
        parent::_initialize();
    }
    public function getBanner(){
        $position = request()->post('position','home');
        $slideId = Slide::getSlideIdByPosition($position);
        $this->success('请求成功',SlideItem::getListBySlideId($slideId));
    }

    public function noticeCategory(){
        $this->success('请求成功',SysMessageCategory::getList());
    }

    public function notice(){
        $categoryId = request()->post('categoryId',1);
        $this->success('请求成功',SysMessage::getList($categoryId,$this->auth->id));
    }

    public function noticeDetail(){
        $noticeId = request()->post('noticeId');
        if(empty($noticeId)){
            $this->error('参数错误');
        }
        $message = SysMessage::where('id',$noticeId)->field('id,category_id,title,content,from,image,image,created_at')->find();
        $this->success('请求成功',$message);
    }
}